home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / conquest / update.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-26  |  14.9 KB  |  509 lines

  1. /*conquest is copyrighted 1986 by Ed Barlow.
  2.  *  I spent a long time writing this code & I hope that you respect this.  
  3.  *  I give permission to alter the code, but not to copy or redistribute
  4.  *  it without my explicit permission.  If you alter the code, 
  5.  *  please document changes and send me a copy, so all can have it.  
  6.  *  This code, to the best of my knowledge works well,  but it is my first
  7.  *  'C' program and should be treated as such.  I disclaim any
  8.  *  responsibility for the codes actions (use at your own risk).  I guess
  9.  *  I am saying "Happy gaming", and am trying not to get sued in the process.
  10.  *                                                Ed
  11.  */
  12.  
  13. #include "header.h"
  14. #include <ctype.h>
  15.  
  16. FILE *fnews, *fopen();
  17.  
  18. extern short country;
  19. int attr[MAPX][MAPY];     /*sector attactiveness*/
  20. extern short occ[MAPX][MAPY];
  21. extern short movecost[MAPX][MAPY];
  22.  
  23. /*update nation file*/
  24. update()
  25. {
  26.     register int x,y;
  27.     int moved,armynum,nvynum,done,finis=0,j,i,number=0;
  28.     int food,iron;
  29.     char command[80];
  30.     int execed[MAXNTN];
  31.  
  32.     if ((fnews=fopen(NEWSFILE,"w"))==NULL) {
  33.         printf("error opening news file\n");
  34.         exit(1);
  35.     }
  36.  
  37.     /*run each nation in a random order*/
  38.     country=0;
  39.     execute();
  40.     for(i=0;i<MAXNTN;i++) execed[i]=0;
  41.     system("/bin/date");
  42.     while(finis==0){
  43.         /*get random active nation*/
  44.         country=(rand()%(MAXNTN-1))+1;
  45.         if(ntn[country].active>0) {
  46.             done=0;
  47.             number=0;
  48.             /*Find the next unupdated nation*/
  49.             while(done==0){
  50.                 if((ntn[country].active>0)&&(execed[country]==0)) {
  51.                     done=1;
  52.                     execed[country]=1;
  53.                 }
  54.                 else {
  55.                     country++;
  56.                     number++;
  57.                     if(number>MAXNTN) {
  58.                         finis=1;
  59.                         done=1;
  60.                     }
  61.                     else if(country>=MAXNTN) country=1;
  62.                 }
  63.             }
  64.  
  65.             if(finis==0){
  66.                 printf("updating nation number %d -> %s\n",country,ntn[country].name);
  67.  
  68.                 /*if execute is 0 and PC nation then they did not move*/
  69.                 if((execute()==0)&&(ntn[country].active==1)){
  70.                     printf("nation %s did not move\n",ntn[country].name);
  71. #ifdef CMOVE
  72.                     printf("the computer will move for %s\n",ntn[country].name);
  73.                     fprintf(fnews,"1.\tthe computer will move for %s\n",ntn[country].name);
  74.                     nationrun();
  75. #endif
  76.                 }
  77. #ifdef NPC
  78.                 /*run npc nations*/
  79.                 if(ntn[country].active>=2) nationrun();
  80. #endif
  81.                 /*do magic*/
  82.                 if(magic(country,MI_MONST)==1){
  83.                     if(magic(country,AV_MONST)==1) {
  84.                         if(magic(country,MA_MONST)==1)
  85.                             takeover(5,0);
  86.                         else takeover(3,0);
  87.                     }
  88.                     else takeover(1,0);
  89.                 }
  90.  
  91.                 /*update movement array*/
  92.                 updmove(ntn[country].race);
  93.  
  94.                 /*THIS IS WHERE YOU ZERO THE ATTR MATRIX*/
  95.                 /*calculate sector attractiveness*/
  96.                 for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) {
  97.                     if((sct[x][y].owner==country)&&(isdigit(sct[x][y].vegitation)!=0)){
  98.                         attr[x][y]=attract(x,y,ntn[country].race);
  99.                     }
  100.                     else if(((magic(country,DERVISH)==1)||(magic(country,DESTROYER)==1))&&((sct[x][y].vegitation==ICE)||(sct[x][y].vegitation==DESERT))) {
  101.                         attr[x][y]=36;
  102.                     }
  103.                     else attr[x][y]=0;
  104.                 }
  105.  
  106.                 /*if near capital add to attr*/
  107.                 for(x=ntn[country].capx-2;x<=ntn[country].capx+2;x++)
  108.                     for(y=ntn[country].capy-2;y<=ntn[country].capy+2;y++)
  109.                         if(attr[x][y]>0) attr[x][y]+=20;
  110.  
  111. /*MOVE CIVILIANS based on the ratio of attractivenesses
  112.      *
  113.      * EQUILIBRIUM(1) = A1/(A1+A2) * (P1+P2)
  114.      * EQUILIBRIUM(2) = A2/(A1+A2) * (P1+P2)
  115.      * MOVE 1/5 of way to equilibrium each turn
  116.      * DELTA(1) = (EQUILIBRIUM(1)-P1)/5 = (A1P2-P1A2)/5(A1+A2)
  117.      * DELTA(2) = (EQUILIBRIUM(2)-P2)/5 = (A2P1-P2A1)/5(A1+A2) = -DELTA(1)
  118.      * ij is refered to as 1, xy as 2
  119.      * NOTE AM ADDING 1 to divisor to prevent floating exception errors
  120.      */
  121.                 for(x=0;x<MAPX-1;x++) for(y=0;y<MAPY-1;y++) for(i=(-2);i<=2;i++) for(j=(-2);j<=2;j++)
  122.                 if((x+i>0)&&(x+i<MAPX)&&(x+j>0)&&(x+j<MAPY)&&(sct[x+i][y+j].owner==country)&&(sct[x][y].owner==country)) {
  123.                     moved=(sct[x][y].people*attr[x+i][y+j]-sct[x+i][y+j].people*attr[x][y])/(1+5*(attr[x+i][y+j]+attr[x][y]));
  124.                     sct[x+i][y+j].people += moved;
  125.                     sct[x][y].people -= moved;
  126.                 }
  127.             }
  128.         }
  129.     }
  130.  
  131.     /* run npc nations */
  132. #ifdef LZARD
  133.     puts("updating lizards\n ");
  134.     country = NLIZARD;
  135.     armynum=0;
  136.     /*move to lizard castle*/
  137.     for(armynum=0;armynum<MAXARM;armynum++) if(ASTAT!=GARRISON){
  138.         for(i=AXLOC-1;i<=AXLOC+1;i++) for(j=AYLOC-1;j<=AYLOC+1;j++){
  139.             if((i>=0)&&(j>=0)&&(i<MAPX)&&(j<MAPX)&&(sct[i][j].designation==DCASTLE)){
  140.                 AXLOC=i;
  141.                 AYLOC=j;
  142.             }
  143.         }
  144.         for(i=AXLOC-1;i<=AXLOC+1;i++) for(j=AYLOC-1;j<=AYLOC+1;j++){
  145.             if((i>=0)&&(j>=0)&&(i<MAPX)&&(j<MAPX)&&(sct[i][j].altitude!=WATER)&&(sct[i][j].owner != NLIZARD)&&(rand()%2==0)){
  146.                 AXLOC=i;
  147.                 AYLOC=j;
  148.             }
  149.         }
  150.     }
  151. #endif
  152.  
  153. #ifdef MONSTER
  154.     monster();
  155. #endif
  156.  
  157.     /*run combat*/
  158.     combat();
  159.  
  160.     fprintf(fnews,"3\tNEWS ON WHAT SECTORS HAVE BEEN CAPTURED");
  161.     /*look for any areas where armies alone in sector*/
  162.     prep();
  163.     for(country=1;country<NTOTAL;country++) if(ntn[country].active!=0){
  164.         for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>75){
  165.             if(sct[AXLOC][AYLOC].owner==0){
  166.                 sct[AXLOC][AYLOC].owner=country;
  167.             }
  168.             else if((sct[AXLOC][AYLOC].owner!=country)&&(ntn[country].dstatus[sct[AXLOC][AYLOC].owner]>=WAR)&&(occ[AXLOC][AYLOC]==country)){
  169.  
  170.                 if((sct[AXLOC][AYLOC].owner!=0)&&(ntn[sct[AXLOC][AYLOC].owner].race!=ntn[country].race)) flee(AXLOC,AYLOC,1);
  171.                 fprintf(fnews,"\n3.\tarea %d,%d captured by %s from %s",AXLOC,AYLOC,ntn[country].name,ntn[sct[AXLOC][AYLOC].owner].name);
  172.                 sct[AXLOC][AYLOC].owner=country;
  173.             }
  174.         }
  175.     }
  176.     fprintf(fnews,"\n1\tIMPORTANT WORLD NEWS\n");
  177.  
  178.     for(country=1;country<MAXNTN;country++) 
  179.         if((ntn[country].active>=2)&&((ntn[country].tciv==0)||(sct[ntn[country].capx][ntn[country].capy].owner!=country))) destroy();
  180.  
  181.     /*zero out all recalculated values*/
  182.     for(i=0;i<MAXNTN;i++){
  183.         ntn[i].tsctrs=0;
  184.         ntn[i].tships=0;
  185.         ntn[i].tciv=0;
  186.         ntn[i].tmil=0;
  187.     }
  188.  
  189.     /*for whole map, update one sector at a time, owned sectors only*/
  190.     printf("\nupdating all sectors\n");
  191.     for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) if(sct[x][y].owner!=0) {
  192.  
  193.         /*check all adjacent sectors and decide if met*/
  194.         for(i=x-1;i<=x+1;i++) for(j=y-2;j<=y+2;j++) {
  195.             if(i>=0&&i<MAPX&&j>=0&&j<MAPY&&(sct[i][j].owner!=0)) {
  196.                 if(sct[x][y].owner!=sct[i][j].owner) {
  197.                     if(ntn[sct[x][y].owner].dstatus[sct[i][j].owner]==UNMET) newdip(sct[x][y].owner,sct[i][j].owner);
  198.                     if(ntn[sct[i][j].owner].dstatus[sct[x][y].owner]==UNMET) newdip(sct[i][j].owner,sct[x][y].owner);
  199.                 }
  200.             }
  201.         }
  202.  
  203.         /*update nation file for owner*/
  204.         ntn[sct[x][y].owner].tsctrs++;
  205.         ntn[sct[x][y].owner].tciv += sct[x][y].people;
  206.  
  207.         /*grow populations*/
  208.         if(sct[x][y].people<100) sct[x][y].people+=sct[x][y].people/10;
  209.         else sct[x][y].people+=(ntn[sct[x][y].owner].repro*sct[x][y].people)/100;
  210.  
  211.         /*PRODUCE*/
  212.         /*increase tmin based on mined stuff...*/
  213.         if(sct[x][y].designation==DMINE) {
  214.             iron=sct[x][y].iron*sct[x][y].people;
  215.             if(magic(sct[x][y].owner,MINER)==1) iron*=2;
  216.             if(magic(sct[x][y].owner,STEEL)==1) iron*=2;
  217.             ntn[sct[x][y].owner].tiron += iron;
  218.             ntn[sct[x][y].owner].tgold += iron*TAXIRON/100;
  219.         }
  220.         /*harvest food*/
  221.         else if(sct[x][y].designation==DFARM) {
  222.             food=todigit(sct[x][y].vegitation)*sct[x][y].people;
  223.             ntn[sct[x][y].owner].tfood += food;
  224.             ntn[sct[x][y].owner].tgold += food*TAXFOOD/100;
  225.         }
  226.         /*gold mines produce gold*/
  227.         else if(sct[x][y].designation==DGOLDMINE) {
  228.             if(magic(sct[x][y].owner,MINER)==1){
  229.                 ntn[sct[x][y].owner].tgold+=  2*sct[x][y].gold * sct[x][y].people * TAXGOLD/100;
  230.                 ntn[sct[x][y].owner].jewels+= 2*sct[x][y].gold * sct[x][y].people;
  231.             }
  232.             else {
  233.                 ntn[sct[x][y].owner].tgold+= sct[x][y].gold * sct[x][y].people * TAXGOLD/100;
  234.                 ntn[sct[x][y].owner].jewels+= sct[x][y].gold * sct[x][y].people;
  235.             }
  236.         }
  237.         else if(sct[x][y].designation==DCAPITOL) {
  238.             if((x!=ntn[sct[x][y].owner].capx)&&(y!=ntn[sct[x][y].owner].capy)) {
  239.                 ntn[sct[x][y].owner].tgold+= 2*sct[x][y].people * TAXCITY/100;
  240.                 sct[x][y].designation=DCITY;
  241.                 if(magic(sct[x][y].owner,ARCHITECT)==1){
  242.                     ntn[sct[x][y].owner].tgold+= 2 * sct[x][y].people * TAXCITY/100;
  243.                 }
  244.                 else {
  245.                     ntn[sct[x][y].owner].tgold+= sct[x][y].people * TAXCITY/100;
  246.                 }
  247.             }
  248.             else if(magic(sct[x][y].owner,ARCHITECT)==1){
  249.                 ntn[sct[x][y].owner].tgold+= 2 * sct[x][y].people * TAXCAP/100;
  250.             }
  251.             else 
  252.                 ntn[sct[x][y].owner].tgold+= sct[x][y].people * TAXCAP/100;
  253.         }
  254.         else if(sct[x][y].designation==DCITY) {
  255.             if(magic(sct[x][y].owner,ARCHITECT)==1){
  256.                 ntn[sct[x][y].owner].tgold+= 2*sct[x][y].people * TAXCITY/100;
  257.             }
  258.             else {
  259.                 ntn[sct[x][y].owner].tgold+= sct[x][y].people * TAXCITY/100;
  260.             }
  261.         }
  262.         else if(((magic(country,DERVISH)==1)||(magic(country,DESTROYER)==1))&&((sct[x][y].vegitation==ICE)||(sct[x][y].vegitation==DESERT))&&(sct[x][y].people>0)) {
  263.             food=6*sct[x][y].people;
  264.             ntn[sct[x][y].owner].tfood += food;
  265.             ntn[sct[x][y].owner].tgold += food*TAXFOOD/100;
  266.         }
  267.     }
  268.  
  269.     /*reset military stuff*/
  270.     printf("updating armies and navies\n");
  271.     for(country=1;country<MAXNTN;country++) if(ntn[country].active!=0){
  272.         for(armynum=0;armynum<MAXARM;armynum++){
  273.             if(ASOLD>0) {
  274.                 ntn[country].tmil+=ASOLD;
  275.                 if(magic(country,VAMPIRE)!=1)
  276.                     ntn[country].tgold-=ASOLD*SOLDMAINT;
  277.  
  278.                 /*add movement to all armies */
  279.                 switch(ASTAT) {
  280.                 case MARCH:
  281.                     AMOVE=2*ntn[country].maxmove;
  282.                     break;
  283.                 case SCOUT:
  284.                 case ATTACK:
  285.                 case DEFEND:
  286.                     AMOVE=ntn[country].maxmove;
  287.                     break;
  288.                 case GARRISON:
  289.                     AMOVE=0;
  290.                     break;
  291.                 default:
  292.                     ASTAT=DEFEND;
  293.                     AMOVE=ntn[country].maxmove;
  294.                 }
  295.             }
  296.         }
  297.         /*add to movement of fleets*/
  298.         for(nvynum=0;nvynum<MAXNAVY;nvynum++) {
  299.             /*update sea sectors*/
  300.             if(NMER+NWAR>0) {
  301.                 if(sct[NXLOC][NYLOC].altitude==WATER) {
  302.                     /*all ships sunk on 0 (d12)*/
  303.                     /*pirates never are sunk (implicitly)*/
  304.                     if(rand()%12==0){
  305.                         fprintf(fnews,"3.\tstorm in %d,%d\n",x,y);
  306.                         NWAR=0;
  307.                         NMER=0;
  308.                     }
  309.                 }
  310.                 NMOVE=3*ntn[country].maxmove;
  311.                 ntn[country].tships+=NWAR+NMER;
  312.                 ntn[country].tgold-=(NWAR+NMER)*SHIPMAINT;
  313.             }
  314.             else {
  315.                 NWAR=0;
  316.                 NMER=0;
  317.             }
  318.         }
  319.     }
  320.  
  321.     /*commodities: feed the people, too much gold?, validate iron*/
  322.     fprintf(fnews,"2\tSTATUS OF THE WORLDS FOOD SUPPLY\n");
  323.     for(country=1;country<MAXNTN;country++) if(ntn[country].active!=0){
  324.         /*soldiers eat  2*/
  325.         ntn[country].tfood-=ntn[country].tmil*2;
  326.         /*civilians eat 1*/
  327.         ntn[country].tfood-=ntn[country].tciv;
  328.  
  329.         /*starve people*/
  330.         if(ntn[country].tfood<0) for(x=0;x<MAPX;x++) for(y=0;y<MAPX;y++) {
  331.             if((sct[x][y].owner==country)&&((sct[x][y].designation==DCITY)||(sct[x][y].designation==DCAPITOL))&&(ntn[country].tfood<0)){
  332.                 /*lose one person in city per three food*/
  333.                 /*maximum of 1/3 people in city lost*/
  334.                 if(sct[x][y].people>(-1)*ntn[country].tfood){
  335.                     sct[x][y].people+=ntn[country].tfood/3;
  336.                     ntn[country].tfood=0;
  337.                 }
  338.                 else {
  339.                     ntn[country].tfood+=sct[x][y].people;
  340.                     sct[x][y].people*=(2/3);
  341.                 }
  342.                 fprintf(fnews,"2.\tfamine hits city at %d,%d in %s.\n",x,y,ntn[country].name);
  343.             }
  344.         }
  345.  
  346.         /*this state can occur if few people live in cities*/
  347.         if(ntn[country].tfood<0) {
  348.             ntn[country].tfood=0;
  349.         }
  350.         else if(ntn[country].tfood>FOODTHRESH*ntn[country].tciv) {
  351.             ntn[country].tgold+=ntn[country].tfood-FOODTHRESH*ntn[country].tciv;
  352.             ntn[country].tfood=FOODTHRESH*ntn[country].tciv;
  353.         }
  354.  
  355.         if(ntn[country].tgold>GOLDTHRESH*ntn[country].jewels){
  356.             x=ntn[country].tgold-GOLDTHRESH*ntn[country].jewels;
  357.             ntn[country].jewels += x/GOLDTHRESH;
  358.             ntn[country].tgold  -= x;
  359.         }
  360.         else if(ntn[country].tgold<((-1)*JEWELTHRESH)*ntn[country].jewels){
  361.             fprintf(fnews,"3.\tTAX REVOLT IN NATION %s\n",ntn[country].name);
  362.         }
  363.     }
  364.  
  365.     fclose(fnews);
  366.     score();
  367.     strcpy(command,"> ");
  368.     strcat(command,EXEFILE);
  369.     system(command);
  370.     strcpy(command,"/bin/sort -n -o ");
  371.     strcat(command,NEWSFILE);
  372.     strcat(command," ");
  373.     strcat(command,NEWSFILE);
  374.     printf("sort done\n");
  375.     system(command);
  376. }
  377.  
  378. attract(x,y,race)
  379. {
  380.     int Attr=0;
  381.  
  382.     if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>3)){
  383.         if(ntn[sct[x][y].owner].jewels<=ntn[sct[x][y].owner].tgold*GOLDTHRESH) Attr+=120;
  384.         else if(sct[x][y].gold>5) Attr+=120;
  385.         else Attr+=75;
  386.     }
  387.     else if((sct[x][y].designation==DFARM)&&(todigit(sct[x][y].vegitation)>6)){
  388.         if(ntn[sct[x][y].owner].tfood<=ntn[sct[x][y].owner].tciv*FOODTHRESH) Attr+=300;
  389.         else if(todigit(sct[x][y].vegitation)==9) Attr+=100;
  390.         else Attr+=40;
  391.     }
  392.     else if(sct[x][y].designation==DCAPITOL) Attr+=200;
  393.     else if(sct[x][y].designation==DCITY) Attr+=125;
  394.     else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>3)) {
  395.         if(ntn[sct[x][y].owner].tiron<=ntn[sct[x][y].owner].tciv)
  396.             Attr+=120;
  397.         else if(sct[x][y].iron>5) Attr+=100;
  398.         else Attr+=50;
  399.     }
  400.  
  401.     switch(race){
  402.     case DWARF:
  403.         if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
  404.             Attr+=100;
  405.         else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>=5))
  406.             Attr+=100;
  407.  
  408.         if(sct[x][y].altitude==MOUNTAIN) Attr+=40;
  409.         else if(sct[x][y].altitude==HILL) Attr+=20;
  410.         else if(sct[x][y].altitude==CLEAR) Attr+=0;
  411.         else Attr=0;
  412.         break;
  413.     case ELF:
  414.         if(sct[x][y].vegitation==JUNGLE) Attr+=40;
  415.         else if(sct[x][y].vegitation==WOOD) Attr+=90;
  416.         else if(sct[x][y].vegitation==FORREST) Attr+=70;
  417.  
  418.         if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
  419.             Attr+=75;
  420.  
  421.         if(sct[x][y].altitude==MOUNTAIN) Attr-=20;
  422.         else if(sct[x][y].altitude==HILL) Attr-=10;
  423.         else if(sct[x][y].altitude==CLEAR) Attr+=0;
  424.         else Attr=0;
  425.         break;
  426.     case HUMAN:
  427.         Attr+=todigit(sct[x][y].vegitation)*4;
  428.  
  429.         if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
  430.             Attr+=75;
  431.         else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>=5))
  432.             Attr+=75;
  433.         else if((sct[x][y].designation==DFARM)&&(todigit(sct[x][y].vegitation)>=6))
  434.             Attr+=55;
  435.         else if(sct[x][y].designation==DCAPITOL) Attr+=70;
  436.         else if(sct[x][y].designation==DCITY) Attr+=50;
  437.  
  438.         if(sct[x][y].altitude==MOUNTAIN) Attr-=10;
  439.         else if(sct[x][y].altitude==HILL) Attr+=00;
  440.         else if(sct[x][y].altitude==CLEAR) Attr+=10;
  441.         else Attr=0;
  442.         break;
  443.     case ORC:
  444.         if(sct[x][y].designation==DCAPITOL) Attr+=120;
  445.         else if(sct[x][y].designation==DCITY) Attr+=75;
  446.         else if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
  447.             Attr+=75;
  448.         else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>=5))
  449.             Attr+=75;
  450.  
  451.         if(sct[x][y].altitude==MOUNTAIN) Attr+=20;
  452.         else if(sct[x][y].altitude==HILL) Attr+=10;
  453.         else if(sct[x][y].altitude==CLEAR) Attr+=0;
  454.         else Attr=0;
  455.         break;
  456.     default:
  457.         break;
  458.     }
  459.     if((Attr<0)||(movecost[x][y]<0)) Attr=0;
  460.     return(Attr);
  461. }
  462.  
  463. todigit(character)
  464. {
  465.     int j;
  466.     for(j=0;j<=9;j++) if(character==*(numbers+j)) return(j);
  467.     return(0);
  468. }
  469.  
  470. armymove(armynum)
  471. {
  472.     int sum,done,place;
  473.     register int x,y;
  474.     sum=0;
  475.     for(x=AXLOC-2;x<=AXLOC+2;x++)
  476.         for(y=AYLOC-2;y<=AYLOC+2;y++)
  477.             if(x>=0&&x<MAPX&&y>=0&&y<MAPY)
  478.                 sum+=attr[x][y];
  479.  
  480.     if(sum==0) {
  481.         AXLOC=ntn[country].capx;
  482.         AYLOC=ntn[country].capy;
  483.         sum=1;
  484.     }
  485.     else {
  486.         place=rand()%sum;
  487.         done=0;
  488.         for(x=AXLOC-2;x<=AXLOC+2;x++) for(y=AYLOC-2;y<=AYLOC+2;y++) {
  489.             if(x>=0&&x<MAPX&&y>=0&&y<MAPY) place-=attr[x][y];
  490.             if((done==0)&&(place<0)&&(movecost[x][y]>0)){
  491.                 AXLOC=x;
  492.                 AYLOC=y;
  493.                 done=1;
  494.                 if(sct[x][y].owner==0)
  495.                     sct[x][y].owner=country;
  496.             }
  497.         }
  498.     }
  499. }
  500.  
  501. score()
  502. {
  503.     int x,y;
  504.  
  505.     printf("\nupdating scores for all nations\n");
  506.     for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++)
  507.         if(sct[x][y].people>0) ntn[sct[x][y].owner].score += SECTSCORE;
  508. }
  509.